package unit4.part7;

import java.util.Random;

/**
 * 神
 */
public class God {
    /**
     * 名字
     */
    private String name;
    /**
     * 血量
     */
    private int blood;
    /**
     * 最大攻击力
     */
    private int maxStrength;
    /**
     * 随机数
     */
    private Random random = new Random();

    public God(String name, int blood, int maxStrength) {
        this.name = name;
        this.blood = blood;
        this.maxStrength = maxStrength;
    }

    /**
     * 发起攻击
     */
    public int attack() {
        return random.nextInt(maxStrength);
    }

    /**
     * 受伤
     */
    public void hurt(int strength) {
        blood = blood - strength;
    }

    /**
     * 是否死亡
     */
    public boolean isDead() {
        return blood <= 0;
    }

    public String getName() {
        return name;
    }

    public int getBlood() {
        return blood;
    }
}
